#include <stdio.h>

#define MAX_EXE     9
#define MAX_DLL     20

int main()
{
    int exe_mem[MAX_EXE];    /* memory requirement for the exe's */
    int dll_mem[MAX_DLL];    /* memory requirement for the dll's */
    char exe_dep[MAX_EXE][MAX_DLL+1];    /* program dependencies */
    int num_exe, num_dll, num_records;

    while (scanf("%d %d %d", &num_dll, &num_exe, &num_records) == 3)
    {
        int i;
        int ref_count[MAX_DLL] = { 0 };
        int usage = 0, peek_usage = 0;

        /* Read memory requirements. */
        for (i = 0; i < num_dll; i++)
            scanf("%d", &dll_mem[i]);
        for (i = 0; i < num_exe; i++)
            scanf("%d %s", &exe_mem[i], exe_dep[i]);

        /* Simulate the process. */
        for (i = 0; i < num_records; i++)
        {
            int prog;
            scanf("%d", &prog);
            if (prog > 0)   /* start program */
            {
                const char *dep = exe_dep[prog-1];
                for (; *dep; dep++)
                {
                    if (++ref_count[*dep - 'A'] == 1)
                        usage += dll_mem[*dep - 'A'];
                }
                usage += exe_mem[prog-1];
            }
            else            /* end program */
            {
                const char *dep = exe_dep[~prog];
                for (; *dep; dep++)
                {
                    if (--ref_count[*dep - 'A'] == 0)
                        usage -= dll_mem[*dep - 'A'];
                }
                usage -= exe_mem[~prog];
            }
            if (usage > peek_usage)
                peek_usage = usage;
        }
        printf("%d\n", peek_usage);
    }
    return 0;
}
